<template>
    <div>
        <div class="menu-tip">精选推荐</div>
        <div class="menu-con">
            <div class="menu-con-item" v-for="item of list" :key="item.id" @click="goArticle(item.id)">
                <p class="mci-img"><img :src="item.cover_img"></p>
                    <p class="mci-title">{{ item.title }}</p>
            </div>
        </div>
    </div>
</template>

<script>
  export default {
    name: 'Content',
    props: {
      id: String
    },
    data () {
      return {
        list:[]
      }
    },
    mounted () {
      this.getData()
    },
    methods: {
      goArticle(id) {
        this.$router.push({name: 'Article', params: {id: id}})
      },
      getData () {
        this.$axios.get('http://localhost:3000/getArticleList?category_id=' + this.id).then((response) => {
          if (response.data.data){
            let length = response.data.data.length;
            for (let i = 0; i < length; i++) {
              this.list.push(response.data.data[i]);
            }
            this.page++;
          }
        })
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.menu-tip {
  padding-left: 10px;
  color: #b1b1b1;
  font-size: 12px;
  margin: 10px 0;
}
.menu-con {
  overflow: hidden;
  margin: 10px;
}
.menu-con-item {
  width: 45%;
  height: 100px;
  margin: 8px;
  float: left;
  overflow: hidden;
  background-color: #001c2d;
  border-radius: 5px;
}
.mci-img {
  width: 100%;
  height: 70px;
  overflow: hidden;
}
.mci-img img {
  width: 100%;
}
.mci-title {
  color: #fff;
  text-align: left;
  padding-left: 5px;
  line-height: 30px;
  font-size: 10px;
}
</style>
